package com.atguigu.gmall.cart.service.impl;

import com.atguigu.gmall.cart.mapper.CartInfoMapper;
import com.atguigu.gmall.cart.service.CartInfoAsyncService;
import com.atguigu.gmall.model.cart.CartInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author gsy
 * @date 2021年09月07日21:45
 * Description
 */
@Service
public class CartInfoAsyncServiceImpl implements CartInfoAsyncService {
    @Autowired
    private CartInfoMapper cartInfoMapper;
    @Async
    @Override
    public void updateAsync(CartInfo cartInfo) {
        QueryWrapper<CartInfo> cartInfoQueryWrapper = new QueryWrapper<>();
        cartInfoQueryWrapper.eq("user_id",cartInfo.getUserId());
        cartInfoQueryWrapper.eq("sku_id",cartInfo.getSkuId());
        cartInfoMapper.update(cartInfo,cartInfoQueryWrapper);

    }
    @Async
    @Override
    public void insertAysnc(CartInfo cartInfo) {
        cartInfoMapper.insert(cartInfo);
    }
}
